package com.controller.medical;

import com.comm.R;
import com.comm.vo.DrugTableVo;
import com.comm.vo.medicinevo.DrugAllView;
import com.service.medical.StockService;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/medicine/stock")
@Api(value = "药品进销存模块",tags = "库存查询的所有接口API")
@ApiResponses({
        @ApiResponse(code=200,message="请求成功"),
        @ApiResponse(code=404,message="找不到页面"),
        @ApiResponse(code=405,message="请求方法错误"),
        @ApiResponse(code=500,message="后台服务错误")
})
public class StockController {

    @Resource
    private StockService stockService;

    //查询总库存
    @RequestMapping(value = "/findAllDrug", method = RequestMethod.GET)
    @ApiOperation(value = "查询总库存", notes = "查询总库存", httpMethod = "GET", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "每页的条数",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "drugName", value = "药品名称", paramType = "query", dataType = "String", required = false)
    })
    @ResponseBody
    public R findAllDrug(@ApiParam() int currentPage,int pageSize,String drugName) {

        return stockService.findAllDrug(currentPage,pageSize,drugName);
    }

    //根据药品名称查询药品信息
    @RequestMapping(value = "/findDrugByName", method = RequestMethod.GET)
    @ApiOperation(value = "根据药品名称查询药品信息",notes = "根据药品名称查询药品信息",httpMethod = "GET", response = R.class)
    @ApiImplicitParam(name = "drugName",value = "药品名称",paramType = "query",dataType = "String",required = false)
    public R findDrugById(String drugName) {
        return stockService.findDrugByName(drugName);
    }

    //调价
    @RequestMapping(value = "/updatePrice", method = RequestMethod.POST)
    @ApiOperation(value = "调价", notes = "调价", httpMethod = "post", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "drugName",value = "药品名称",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "allStock", value = "库存", paramType = "query", dataType = "String", required = false),
            @ApiImplicitParam(name = "price", value = "处方价(输入的价钱)", paramType = "query", dataType = "int", required = false)
    })
    @ResponseBody
    public R updatePrice(String drugName,String allStock,int price) {

        return stockService.updatePrice(drugName,allStock,price);
    }
    //预警设置
    @RequestMapping(value = "/alert", method = RequestMethod.POST)
    @ApiOperation(value = "预警设置", notes = "预警设置", httpMethod = "post", response = R.class)
    @ApiImplicitParam(name = "allStock", value = "库存", paramType = "query", dataType = "int", required = false)
    @ResponseBody
    public R alert() {
        R r = new R();
        r.setCode(200);
        r.setMsg("修改成功");
        return r;
    }
    //显示批次库存
    @RequestMapping(value = "/findAllOrder", method = RequestMethod.GET)
    @ApiOperation(value = "显示批次库存", notes = "显示批次库存", httpMethod = "GET", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "每页的条数",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "drugName", value = "药品名称", paramType = "query", dataType = "String", required = false)
    })
    @ResponseBody
    public R findAllOrder(@ApiParam() int currentPage,int pageSize,String drugName) {

        return stockService.findAllOrder(currentPage,pageSize,drugName);
    }
}
